/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package exercicio13;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Caio
 */
public class CompositeElement extends DrawingElement {

    private List<DrawingElement> elements = new ArrayList<DrawingElement>();
    
    public CompositeElement(String name) {
        super(name);
    }

    @Override
    public void add(DrawingElement d) {
        elements.add(d);
    }

    @Override
    public void remove(DrawingElement d) {
        elements.remove(d);
    }

    @Override
    public void Display(int ident) {
        System.out.println(" - "+ident+"+ "+name);
        
        for (Iterator<DrawingElement> it = elements.iterator(); it.hasNext();) {
            DrawingElement d = it.next();
                   d.Display(ident+2);
        }

    }
    
}
